package com.ayu.scalalearn.chapter06

/**
  * @Author 徐林玉
  * @Description Test06DynamicalBind
  * @Date 2022/7/29 10:22
  * @Version 1.0
  */
object Test06DynamicBinding {

  def main(args: Array[String]): Unit = {

    //多态的特性 动态绑定
    val w1: PersionTest06 = new Worker()

    w1.hello()

    println(w1.name)

  }


  class PersionTest06 {


    val name: String = "person"

    def hello(): Unit = {

      println("hello person")

    }
  }


  class Worker extends PersionTest06 {

    override val name = "worker"

    override def hello(): Unit = {

      println("hello worker")
    }
  }

}
